//活动安排
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

int main() {
    int n = 0;
    cin >> n;
    vector<pair<int,int>> arr(n);
    for(int i = 0;i < n ;++i)
    {
        cin >> arr[i].first >> arr[i].second;
    }
    std::sort(arr.begin(),arr.end());
    int res = 0;
    int r = arr[0].second;
    for(int i = 1;i < n;++i)
    {
        if(r <= arr[i].first) //要求尽可能选更多的活动
        {
            ++res;
            r = arr[i].second;
        }
        else{
            r = std::min(r,arr[i].second);
        }
    }
    ++res;
    cout << res;
}


//薯条的最萌身高差对数
//排序+滑动窗口+前缀和
const int N = 2e5 + 10;
int n = 0;
int l = 0,r = 0;
int arr[N] = {0};
unsigned long find(int value)
{
    unsigned long res = 0;
    int front = 0,back = 0;
    while(back < n)
    {
        while(arr[back] - arr[front] > value)
        {
            ++front;
        }
        res += back-front;
        ++back;
    }
    return res;
}
int main()
{
    cin >> n >> l >> r;
    for(int i = 0;i < n;++i)
    {
        cin >> arr[i];
    }
    std::sort(arr,arr + n);
    cout << find(r) - find(l-1);
    return 0;